import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-11-02
 * Time: 15:14
 */
public class Test3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        int len = str.length();
        StringBuffer strBuffer = new StringBuffer();
        Stack<Character> stack = new Stack<>();
        for(int i = len - 1; i >= 0; i--) {
            char ch = str.charAt(i);
            if(ch != ' ') {
                stack.push(ch);
            }
            if(ch == ' ' || i == 0) {
                while(!stack.isEmpty()) {
                    strBuffer.append(stack.pop());
                }
                strBuffer.append(' ');
            }
        }
        System.out.println(strBuffer.toString());
    }
}
